package com.aforce3.trailertracer;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

public class Ray
{
	Point3d source;
	Vector3d direction;
	public int depth;
	
	public Ray(Point3d source, Vector3d direction, int depth)
	{
		this.source = source;
		this.direction = direction;
		this.direction.normalize();
		this.depth = depth;
	}
	
	public Point3d getSource()
	{
		return source;
	}
	
	public void setSource(Point3d s)
	{
		source = s;
	}
	
	public Vector3d getDirection()
	{
		return direction;
	}
	
	public int getDepth()
	{
		return depth;
	}
	
	/** Assumes the point is on the ray **/
	public double getDistance(Point3d point)
	{
		Vector3d distance = new Vector3d(point);
		distance.sub(source);
		return distance.length();
	}
}
